import os
import re

# TODO: 替换为5位同学的真实信息！
student_db = {
    # 格式: '学号': ('班级', '姓名')
    '24403000604': ('网工2403', '小王'),
    '24403000607': ('网工2403', '小高'),
    '24403000708': ('网工2403', '小李'),
    '24403000123': ('网工2403', '小张'),
    '24403000456': ('网工2403', '小刘'),
}

def find_matching_student(filename):
    # 匹配学号（11位数字）
    id_match = re.search(r'\b(\d{11})\b', filename)
    if id_match:
        student_id = id_match.group(1)
        if student_id in student_db:
            class_name, name = student_db[student_id]
            return class_name, student_id, name
    
    # 匹配姓名（2-3个汉字）
    name_match = re.search(r'([\u4e00-\u9fa5]{2,3})', filename)
    if name_match:
        name_frag = name_match.group(1)
        for sid, (cls, full_name) in student_db.items():
            if name_frag in full_name:
                return cls, sid, full_name
    return None

def main():
    for filename in os.listdir('.'):
        if filename.lower().endswith('.zip'):
            info = find_matching_student(filename)
            if info:
                new_name = f"{info[0]}-{info[1]}-{info[2]}.zip"
                os.rename(filename, new_name)
                print(f"重命名: {filename} -> {new_name}")
            else:
                print(f"跳过: {filename}（未匹配学生信息）")

if __name__ == '__main__':
    main()